<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.googlecode.contests_repo.core.config.ConfigurationManager"%>
<%@ page import="com.googlecode.contests_repo.core.users.*" %>	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contest Repo - Registration</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="assets/style/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<%@include file="include/header.jsp"%>
	<h1>User registration</h1>
	<jsp:useBean id="user" class="com.googlecode.contests_repo.core.model.User" scope="request">
		<jsp:setProperty name="user" property="*"/>
	</jsp:useBean>
	<%	
		if(request.getParameter("commit") != null) {
			if (user.validate())	{
				UserManager.saveUser(user);
				response.sendRedirect("series_list.jsp");
			}
		}
	%>
	<form method="post" action="">
		<p>
			<label><span class="title"><em>*</em>Username:</span> <input type="text" name="login" value="<%= user.getLogin() %>" /></label>
			<span class="error"><%= user.getValidationError("login") %></span>
		</p> 
		<p>
			<label><span class="title"><em>*</em>Password:</span> <input type="password" name="password" /></label>
			<span class="error"><%= user.getValidationError("password") %></span> 
		</p>
		<p>
			<label><span class="title"><em>*</em>Repeat password:</span> <input type="password" name="confirmPassword" /></label> 
		</p>
		<p>
			<label><span class="title"><em>*</em>E-mail:</span> <input type="text" name="email" value="<%= user.getEmail() %>" /></label>
			<span class="error"><%= user.getValidationError("email") %></span> 
		</p>
		<p>		
			<label><span class="title"><em>*</em>Real name:</span> <input type="text" name="realName" value="<%= user.getRealName() %>" /></label>
			<span class="error"><%= user.getValidationError("realName") %></span> 
		</p>
		<p>		
			<label><span class="title">City:</span> <input type="text" name="city" value="<%= user.getCity() %>" /></label>
		</p>
		<p> 
			<label><span class="title">Organization:</span> <input type="text" name="organizations" value="<%= user.getOrganizations()[0] %>" /></label>
		</p>
		<p>
			<label><span class="title">About:</span><textarea rows="3" cols="40" name="about" ><%= user.getAbout() %></textarea></label>
		</p>
		<p><button name="commit" value="1" class="submit">register</button></p>
	</form>

</body>
</html>